﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Outdoors.Helpers.Flickr;

namespace Outdoors
{
    public partial class FlickrSearchResults : PhoneApplicationPage
    {
        private double Latitude { get; set; }
        private double Longitude { get; set; }
        public FlickrSearchResults()
        {
            InitializeComponent();

            Loaded += FlickrSearchResults_Loaded;
        }

        private async void FlickrSearchResults_Loaded(object sender, RoutedEventArgs e)
        {
            var flickrImages = await FlickrImage.GetFlickrPhotos(Latitude, Longitude);

            DataContext = flickrImages;
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            Latitude = Convert.ToDouble(NavigationContext.QueryString["latitude"]);
            Longitude = Convert.ToDouble(NavigationContext.QueryString["longitude"]);
        }
    }
}